package com.cyl.wechat;

import com.github.wxpay.sdk.WXPayConfig;
import org.springframework.core.io.ClassPathResource;

import java.io.InputStream;

public class MyWxPayConfig implements WXPayConfig {

    // 微信支付配置参数
    private static final String APP_ID = "wxfa5c50e6591be95f";
    private static final String MCH_ID = "1727258011";
    private static final String API_KEY = "beijingshangyu123456789123456789";

    @Override
    public String getAppID() {
        return APP_ID;
    }

    @Override
    public String getMchID() {
        return MCH_ID;
    }

    @Override
    public String getKey() {
        return API_KEY;
    }

    @Override
    public InputStream getCertStream() {
        try {
            // 从resources目录加载证书
            ClassPathResource resource = new ClassPathResource("cert/apiclient_cert.p12");
            return resource.getInputStream();
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
